<template>
  <div>

    <div v-if="!isShowClientele">
      <van-nav-bar title="" left-text="返回" right-text="进库" left-arrow @click-left="onClickLeft" @click-right="onClickRight" />
      列表
    </div>
    <div v-if="isShowClientele">
      <van-nav-bar title="" left-text="返回" left-arrow @click-left="onClienteleClickLeft" />
      <van-grid :column-num="2">
        <van-grid-item v-for="(value,keys) in clienteleList" :key="keys" @click="putStorage(keys)">
          <a>{{value.uname}}</a>
        </van-grid-item>
      </van-grid>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        isShowClientele: false,
        clienteleList: {}
      }
    },
    computed: {},
    watch: {},
    created() {
      const _this = this
      this.clienteleList = this.$help.Cache('clientele')
      if (this.clienteleList === false) {
        const _this = this
        this.$help.Request.get('/fule/clientele').then(res => {
          _this.clienteleList = res['data']
          _this.$help.Cache('clientele', res['data'], 3600)
        })
      }
    },
    methods: {
      onClickLeft() {
        this.$router.push('/')
      },
      onClickRight() {
        this.isShowClientele = true
      },
      onClienteleClickLeft() {
        this.isShowClientele = false
      },
      putStorage(clienteleID) {
        this.$router.push({
          name: 'Storage',
          params: {
            clientele_id: clienteleID
          }
        })

      }
    }
  }
</script>

<style>
</style>
